package cn.gson.fengboot.controller;

import cn.gson.fengboot.model.pojos.Zreturnedmoney;
import cn.gson.fengboot.model.pojos.Zreturnedmoneylog;
import cn.gson.fengboot.model.service.ZreturnedmoneyService;
import cn.gson.fengboot.model.service.ZreturnedmoneylogService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/hkjl")
public class ZreturnedmoneylogController {
    @Autowired
    ZreturnedmoneylogService hkjlservice;

    @RequestMapping("/hkjl_list")
    @ResponseBody
    public Map<String,Object> kaipiao(Integer page, Integer size,String search,String search2){
        Page<Object> obj = PageHelper.startPage(page, size);
        hkjlservice.hkjllist(search,search2);

        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    @RequestMapping("/hkjl_list2")
    @ResponseBody
    public Map<String,Object> kaipiao2(Integer page, Integer size,String search,String search2){
        Page<Object> obj = PageHelper.startPage(page, size);
        hkjlservice.hkjllist2(search,search2);

        Map<String,Object> map = new HashMap<>();
        map.put("total",obj.getTotal());
        map.put("rows",obj.getResult());
        return map;
    }

    @RequestMapping("/hkjh_jl")
    @ResponseBody
    public List<Zreturnedmoneylog> jhjl(Integer hkid){

        return hkjlservice.jhjl(hkid);
    }


    @RequestMapping("/add_jh")
    @ResponseBody
    public void add(@RequestBody Zreturnedmoneylog jh){
        System.out.println(jh);
        hkjlservice.addfapiao(jh);
    }

}
